package DirDataAPI

import (
	"os"
	"os/exec"
	"strings"
)

/*
	返回URL-key参数
*/
func URLkey(URL string) string {
	var Position int = strings.Index(URL, "key=") + 4
	s := []byte(URL)
	return string(s[Position : Position+32])
}

/*
	返回URL-MD5参数
*/
func URLMD5(URL string) string {
	var Position int = strings.Index(URL, "MD5=") + 4
	s := []byte(URL)
	return string(s[Position : Position+32])
}

/*
	返回当前运行目录
*/
func GetCurrentPath() string {
	s, err := exec.LookPath(os.Args[0])
	checkErr(err)
	return string(s[0 : strings.LastIndex(s, "\\")+1])
}

/*
	错误处理
*/
func checkErr(err error) {
	if err != nil {
		panic(err)
	}
}
